import json
from datetime import datetime
import time

data = {
    "packetType": "http",
    "data": {
            "id": "4BBC3FE977D042B2970AD75D70E33E04",
            "httpType": 1,
            "host": "10.10.2.236:31260",
            "port": 31260,
            "httpDirection": 2,
            "uri": "/api/system/login",
            "fullUri": "http://10.10.2.236:31260/api/system/login",
            "requestIp": "127.0.0.2",
            "requestMethod": "POST",
            "requestTime": None,
            "requestTimestamp": None,
            "requestTimestampStr": None,
            "requestContentLength": 110,
            "requestContentType": "application/json",
            "requestHeader": "{\"Referer\":\"http://10.10.2.236:31269\",\"Origin\":\"10.10.2.233:31101\",\"X-Forwarded-For\":\"111.111.111.114\",\"User-Agent\":\"python3.9\",\"Accept\":\"text/plain, application/json, application/*+json, */*\",\"Connection\":\"Keep-Alive\",\"Host\":\"10.10.2.240:32381\",\"Accept-Encoding\":\"gzip,deflate\",\"Content-Length\":\"110\",\"Content-Type\":\"application/json\"}",
            "requestBody": "{\"name\": \"aoDdnao8xMaO7rlMTu4LWUFiQ6bQdt1HjFv4pLUiA/jLZS3ItsDL2FA4jD/3PCg9Ft0JaFqeIIEOcl7gfH5opS59y/Le4vANbjzlq8U0oqsTFfVNimYvU7Fa+qcRwv22np0ZhIXJkus07c2sdQasBjbC6vnXC+VV4bNxB4JsZ+Y=\", \"password\": \"g+hnpzTlOxw0++nf3WpsJKj1OrqDRzWPxQv1bvlO/o57ToujnVXDuqMAAqI/Zqdq+LdkO3Vwaq+QRwwgavM5/3/LXVBT5CcwqkuhpAgKw0KLYxBHmfwtM9QI0B+mFig25VrBfHYOLuzD5e+0XDQse+gWTLYxLhshtBn42yGjixg=\", \"publicKeyId\": \"1\" }",
            "sensitiveChars": None,
            "statusCode": 200,
            "costTime": 18,
            "responseIp": "10.10.2.240",
            "responseTime": None,
            "responseTimestamp": None,
            "responseTimestampStr": None,
            "responseContentLength": 0,
            "responseContentType": "application/json",
            "responseHeader": "{\"Set-Cookie\":\"name=123123;SameSite=strict\",\"Access-Control-Allow-Origin\":\"*\",\"Transfer-Encoding\":\"chunked\",\"Keep-Alive\":\"timeout=60\",\"Connection\":\"keep-alive\",\"Vary\":\"Access-Control-Request-Headers\",\"Date\":\"Mon, 10 Oct 2022 13:54:38 GMT\",\"Content-Type\":\"application/json\",\"Access-Control-Allow-Origin\":\"*\"}",
            "responseBody": "{\"code\":\"200\",\"msg\":\"hello\"}}",
            "complete": True,
            "project": "scan_api"
    }
}

current_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
current_timestamp = int(time.time() * 1000)

# 替换时间与时间戳
data["data"]["requestTime"] = current_time
data["data"]["requestTimestamp"] = current_timestamp
data["data"]["responseTime"] = current_time
data["data"]["responseTimestamp"] = current_timestamp



with open('../一般报文.txt', 'w') as file:
    json.dump(data, file, indent=4)

print("报文文件已生成！")